
TOPDIR := $(shell pwd)
SRCDIR := $(TOPDIR)/source
INSTALLDIR := $(TOPDIR)/linux
EXAMPLEDIR := $(TOPDIR)/examples

CMAKE_FLAGS := -DCMAKE_INSTALL_PREFIX=$(INSTALLDIR)

all:
	@make clone
	@make config
	@make compile
	@make install
	@make demo

help:
	@echo 'Usage: make [clone|config|compile|install|demo|clean|distclean]'

clone:
	git clone https://github.com/libuv/libuv.git source
	git clone https://github.com/nikhilm/uvbook.git
	git clone https://github.com/luohaha/Chinese-uvbook.git

clean:
	@cd $(EXAMPLEDIR) && make clean

distclean:
	@rm linux source uvbook Chinese-uvbook -rf
	@cd $(EXAMPLEDIR) && make clean

config:
	@echo ' configure libuv'
	@mkdir source/build -p
	cd source/build && cmake $(CMAKE_FLAGS) ..

compile:
	@echo 'Compile libuv'
	cd source/build && make

install:
	@mkdir linux -p
	@echo 'install libuv'
	cd source/build && make install

demo:
	@echo 'make examples'
	@cd $(EXAMPLEDIR) && make
